package online.afeibaili.storebackendframework.service.impl

import online.afeibaili.storebackendframework.model.CouponEntity
import online.afeibaili.storebackendframework.repository.CouponRepository
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import kotlin.jvm.optionals.getOrNull


/**
 * 优惠券的逻辑类
 *
 *@author AfeiBaili
 *@version 2025/10/25 22:04
 */

@Service
class CouponServiceImpl {

    @Autowired
    lateinit var repository: CouponRepository

    fun getAll(): List<CouponEntity> {
        return repository.findAll()
    }

    fun getById(id: Long): CouponEntity? {
        return repository.findById(id).getOrNull()
    }

    fun getByIds(ids: List<Long>): List<CouponEntity> {
        return repository.findByCreateTimeIn(ids)
    }
}